package JdbcTemplate.operation;

import JdbcTemplate.config.Config;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.jdbc.core.JdbcOperations;

public class Insert_update_delete {

    public static void main(String[] args) {

        String addData="INSERT INTO spitter (PASSWORD,first_name,last_name,email) " +
                "VALUES(?,?,?,?)";
        String deleteData="DELETE FROM spitter WHERE id_identity=?;";

        String update="UPDATE spitter SET PASSWORD=4444444444  WHERE id_identity=?";

        ApplicationContext configApplicationContext=new
                AnnotationConfigApplicationContext(Config.class);
        JdbcOperations jdbcOperations= (JdbcOperations) configApplicationContext.getBean("jdbcOperations");
            //向数据库添加数据
            jdbcOperations.update(addData,"1234","黄","彪","234@sina.com");
            //删除数据
            jdbcOperations.update(deleteData,4);
            //修改数据
            jdbcOperations.update(update,15);


    }
}
